Punjab University Solved Past Paper 2020

Define enterprise application development.

Enterprise Application Development is a complex process of creating applications for business purposes. They are complex, customized for critical business requirements, and can be deployed on the cloud, on a variety of platforms across corporate networks, intranet, etc. Enterprise application development is where a company develops bespoke software or mobile tech to improve its business. This can be because they want to drive efficiency, streamline their operations or better engage their employees.



What do you mean by XML deployment descriptors?

A web application's deployment descriptor describes the classes, resources, and configuration of the application and how the web-server uses them to serve web requests. Deployment descriptor (web.xml) helps us to configure and provide mapping for URLs to respective servlets or JSP's. It is the configuration file used to specify security filters, error page handlers, default pages, etc.


Why CORBA uses an interface definition language?

The CORBA Interface Definition Language, or IDL, allows the development of language and location-independent interfaces to distributed objects. Using CORBA, application components can communicate with one another no matter where they are located, or who has designed them.


State the difference between stateful and stateless session beans?

Stateless session beans do not maintain the state associated with any client. Each stateless session bean can server multiple clients. Stateful session beans maintain the state associated with a client. Each stateful session bean serves exactly one client.


What is defined as web components?

Web components are a set of web platform APIs that allow you to create new custom, reusable, encapsulated HTML tags to use in web pages and web apps. Web The component is a suite of different technologies allowing you to create reusable custom elements — with their functionality encapsulated away from the rest of your code — and utilize them in your web apps.


Name and define different types of Enterprise Bean.

Enterprise JavaBeans (EJBs) can be one of three types: session beans, entity beans, or message-driven beans. Session beans can be stateful or stateless and are used for business logic functionality. Stateless session beans are used for business services. They do not retain client states across calls.


Define Servlets.

A servlet is a Java programming language class that is used to extend the capabilities of servers that host applications accessed using a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by web servers.


Write down the steps for the creation of stateless EJB.

Steps to Create a Stateless EJB

Use @Local annotation, if the EJB client is in the same environment where the EJB session bean is to be deployed. Use @Remote annotation, if the EJB client is the indifferent environment where the EJB session bean is to be deployed. Create a stateless session bean, implementing the above interface.


Name core J2ee technologies?


  • JDBC(Java Database Connectivity)
  • JNDI(Java Name and Directory Interface)
  • EJB (Enterprise JavaBeans)
  • RMI(Remote Method Invoke)
  • The Java IDL/CORBA
  • JSP(Java Server Pages)
  • Java Servlet
  • XML(Extensible Markup Language)
  • JMS(Java Message Service)
  • JTA(Java Transaction Architecture)
  • JTS(Java Transaction Service)
  • JavaMail
  • JAF(JavaBeans Activation Framework)


Define JMS?

Java Message Service (JMS) is an application program interface (API) from Sun Microsystems supports the formal communication known as messaging between computers in a network. Sun's JMS provides a common interface to standard messaging protocols and also to special messaging services in support of Java programs.


Long Questions


What is a servlet? Define the complete life cycle of the java servlet with all function details.

A servlet is a Java programming language class that is used to extend the capabilities of servers that host applications accessed using a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by web servers. A servlet life cycle can be defined as the entire process from its creation to destruction. The following are the paths followed by a servlet.


  • The servlet is initialized by calling the init() method.
  • The servlet calls service() method to process a client's request.
  • The servlet is terminated by calling the destroy() method.
  • Finally, the servlet is garbage collected by the garbage collector of the JVM

Now let us discuss the life cycle methods in detail.

The init() Method


The init method is called only once. It is called only when the servlet is created, and not called for any user requests afterward. So, it is used for one-time initializations, just as with the init method of applets.

The servlet is normally created when a user first invokes a URL corresponding to the servlet, but you can also specify that the servlet is loaded when the server is first started.

When a user invokes a servlet, a single instance of each servlet gets created, with each user request resulting in a new thread that is handed off to doGet or doPost as appropriate. The init() method simply creates or loads some data that will be used throughout the life of the servlet.

The init method definition looks like this −

public void init() throws ServletException {

// Initialization code...

}

The service() Method

The service() method is the main method to perform the actual task. The servlet container (i.e. web server) calls the service() method to handle requests coming from the client( browsers) and to write the formatted response back to the client.

Each time the server receives a request for a servlet, the server spawns a new thread and calls service. The service() method checks the HTTP request type (GET, POST, PUT, DELETE, etc.) and calls doGet, doPost, doPut, doDelete, etc. methods as appropriate.

Here is the signature of this method −

public void service(ServletRequest request,

ServletResponse response)

throws ServletException, IOException {

}


The service () method is called by the container and the service method invokes doGet, doPost, doPut, doDelete, etc. methods as appropriate. So you have nothing to do with the service() method but you override either doGet() or doPost() depending on what type of request you receive from the client.

The doGet() and doPost() are the most frequently used methods in each service request. Here is the signature of these two methods.

The destroy() Method

The destroy() method is called only once at the end of the life cycle of a servlet. This method gives your servlet a chance to close the database connections, halt background threads, write cookie lists or hit counts to disk, and perform other such cleanup activities.

After the destroy() method is called, the servlet object is marked for garbage collection.

The destroy method definition looks like this −

public void destroy() {

// Finalization code...

}


What is RMI? Explain the purpose of it's each component with the help of examples.

The RMI (Remote Method Invocation) is an API that provides a mechanism to create distributed applications in java. The RMI allows an object to invoke methods on an object running in another JVM. The RMI provides remote communication between the applications using two objects stub and skeleton.

RMI stands for Remote Method Invocation. It is a mechanism that allows an object residing in one system (JVM) to access/invoke an object running on another JVM.

RMI is used to build distributed applications; it provides remote communication between Java programs. It is provided in the package java.rmi.

The architecture of an RMI Application

In an RMI application, we write two programs, a server program (resides on the server) and a client program (resides on the client).

  • Inside the server program, a remote object is created, and a reference of that object is made available for the client (using the registry).
  • The client program requests the remote objects on the server and tries to invoke its methods.

let us now discuss the components of this architecture.


  • Transport Layer − This layer connects the client and the server. It manages the existing connection and also sets up new connections.
  • Stub − A stub is a representation (proxy) of the remote object at the client. It resides in the client system; it acts as a gateway for the client program.
  • Skeleton − This is the object which resides on the server-side. stub communicates with this skeleton to pass requests to the remote object.
  • RRL(Remote Reference Layer) − It is the layer that manages the references made by the client to the remote object.

Working of an RMI Application

The following points summarize how an RMI application works

  • When the client makes a call to the remote object, it is received by the stub which eventually passes this request to the RRL.
  • When the client-side RRL receives the request, it invokes a method called invoke() of the object remoteRef. It passes the request to the RRL on the server-side.
  • The RRL on the server-side passes the request to the Skeleton (proxy on the server) which finally invokes the required object on the server.
  • The result is passed all the way back to the client.

What is JSP? Explain its life cycle by giving the name and purpose of each function that is called in it.

Java Server Page Stands for "Java Server Page." This standard was developed by Sun Microsystems as an alternative to Microsoft's active server page (ASP) technology. JSP pages are similar to ASP pages in that they are compiled on the server, rather than in a user's Web browser.

A JSP life cycle is defined as the process from its creation till destruction. This is similar to a servlet life cycle with an additional step that is required to compile a JSP into the servlet.

Paths Followed By JSP The following are the paths followed by a JSP −

  • Compilation
  • Initialization
  • Execution
  • Cleanup


The four major phases of a JSP life cycle are very similar to the Servlet Life Cycle. The
four phases have been described below −

  • JSP Compilation
  • JSP Initialization
  • JSP Execution
  • JSP CleanUP

JSP Compilation

When a browser asks for a JSP, the JSP engine first checks to see whether it needs to compile the page. If the page has never been compiled, or if the JSP has been modified since it was last compiled, the JSP engine compiles the page.

The compilation process involves three steps −

  • Parsing the JSP.
  • Turning the JSP into a servlet.
  • Compiling the servlet.

JSP Initialization

When a container loads a JSP it invokes the jspInit() method before servicing any requests. If you need to perform JSP-specific initialization, override the jspInit() method −

public void jspInit(){
// Initialization code...
}

Typically, initialization is performed only once, and as with the servlet init method, you generally, initialize database connections, open files, and create lookup tables in the jspInit method.


JSP Execution

This phase of the JSP life cycle represents all interactions with requests until the JSP is destroyed. Whenever a browser requests a JSP and the page has been loaded and initialized, the JSP engine invokes the _jspService() the method in the JSP.

The _jspService() method takes an HttpServletRequest and an HttpServletResponse has its parameters as follows −

void _jspService(HttpServletRequest request, HttpServletResponse
response) {
// Service handling code...
}

The _jspService() method of a JSP is invoked on a request basis. This is responsible for generating the response for that request and this method is also responsible for generating responses to all seven of the HTTP methods, i.e, GET, POST, DELETE, etc.

JSP Cleanup

The destruction phase of the JSP life cycle represents when a JSP is being removed from use by a container. The jspDestroy() method is the JSP equivalent of the destroy method for servlets. Override jspDestroy when you need to perform any cleanup, such as releasing database connections or closing open files.

The jspDestroy() method has the following form −
public void jspDestroy() {
// Your cleanup code goes here.
}

See Enterprice Application Punjab University Solved Past Paper 2019

Get updates in your Inbox
Subscribe